import { isPlainObject } from './util'

export function tranformRequest(data: any): any {
  return isPlainObject(data) ? JSON.stringify(data) : data
}

export function tranformResponse(data: any): any {
  if (typeof data === 'string') {
    try {
      data = JSON.parse(data)
    } catch (error) {
      // 啥都不干，反正转换出错了，最后还是要返回data
    }
  }

  return data
}
